package com.yupi.xunji.once;
import java.util.Date;

import com.yupi.xunji.mapper.UserMapper;
import com.yupi.xunji.model.domain.User;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

@Component
public class InsertUsers {
    @Resource
    private UserMapper userMapper;

//    @Scheduled(initialDelay = 5000,fixedRate = Long.MAX_VALUE)
    public void insertUsers(){
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUMBER = 1000;
        for (int i = 0;i < INSERT_NUMBER;i++){
            User user = new User();
            user.setUsername("fakeZys");
            user.setUserAccount("fake");
            user.setGender(0);
            user.setUserPassword("123456789");
            user.setPhone("15206083829");
            user.setEmail("123456789@qq.com");
            user.setUserStatus(0);
            user.setCreateTime(new Date());
            user.setUpdateTime(new Date());
            user.setIsDelete(0);
            user.setUserRole(0);
            user.setPlanetCode("66666");
            user.setTags("[]");
            userMapper.insert(user);
        }
        stopWatch.stop();
        System.out.println(stopWatch.getTotalTimeMillis());
    }
}
